Skip to content

Refactor PostgreSQLExecutor to support Windows compatibility for process management#1182

Open
tboy1337 wants to merge 35 commits intodbfixtures:mainfrom
tboy1337:edit
Open

Refactor PostgreSQLExecutor to support Windows compatibility for process management#1182
tboy1337 wants to merge 35 commits intodbfixtures:mainfrom
tboy1337:edit

Conversation

@tboy1337
Copy link
Copy Markdown
Contributor

@tboy1337 tboy1337 commented Aug 30, 2025

Refactors PostgreSQLExecutor to improve Windows compatibility and security for PostgreSQL process management. This change addresses platform-specific issues with process termination and command formatting that could cause failures on Windows systems.

Changes

  • Unified command format: Converted _get_base_command method to BASE_PROC_START_COMMAND class attribute with cross-platform compatible syntax (removed single quotes around PostgreSQL config values that caused issues on Windows)
  • Graceful Windows termination: Added _windows_terminate_process method that attempts graceful shutdown before force-killing stuck processes
  • Improved security: Updated stop() method to use list arguments instead of shell=True to prevent shell injection vulnerabilities
  • Platform-specific logic: Added intelligent platform detection with fallback handling for os.killpg AttributeError on Windows
  • Comprehensive test coverage: Added 186 lines of Windows compatibility tests covering various termination scenarios and command formatting

Test plan

  • ✅ New test suite in tests/test_windows_compatibility.py with 7 test cases
  • ✅ Tests verify unified command format without single quotes
  • ✅ Tests verify graceful termination and force-kill timeout handling
  • ✅ Tests verify platform-specific stop behavior (Windows vs Unix)
  • ✅ Tests verify fallback logic for killpg AttributeError
  • ✅ Tests verify command formatting with Windows paths

Summary by CodeRabbit

Release Notes

  • New Features

    • Improved Windows compatibility with platform-specific process start commands and enhanced process termination handling.
    • Added support for locale configuration on macOS (en_US.UTF-8) and Windows (C).
  • Tests

    • Expanded test coverage for Windows and Unix/Linux command construction.
    • Added Windows CI testing with PostgreSQL 16, 17, and 18 across Python 3.12–3.14.

@tboy1337 tboy1337 mentioned this pull request Aug 30, 2025
Comment thread pytest_postgresql/executor.py
Comment thread pytest_postgresql/executor.py Outdated
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jan 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4c496081-ca72-49a2-9890-f8415016e31f

📥 Commits

Reviewing files that changed from the base of the PR and between 9090ace and 87abf24.

📒 Files selected for processing (8)
  • .github/workflows/dockerised-postgres.yml
  • .github/workflows/oldest-postgres.yml
  • .github/workflows/single-postgres.yml
  • .github/workflows/tests.yml
  • newsfragments/1182.feature.rst
  • pytest_postgresql/executor.py
  • tests/test_executor.py
  • tests/test_windows_compatibility.py
✅ Files skipped from review due to trivial changes (2)
  • newsfragments/1182.feature.rst
  • .github/workflows/tests.yml
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/oldest-postgres.yml

📝 Walkthrough

Walkthrough

The PR introduces Windows compatibility for PostgreSQL executor management by implementing platform-specific process start command templates (Unix and Windows variants), adding Windows-specific process termination logic with timeout handling, updating subprocess invocation patterns, and extending CI to test Windows environments with three PostgreSQL versions.

Changes

Cohort / File(s) Summary
Core Windows Compatibility Implementation
pytest_postgresql/executor.py
Added platform-specific command templates (UNIX_PROC_START_COMMAND, WINDOWS_PROC_START_COMMAND); implemented _windows_terminate_process() for graceful Windows process cleanup with timeout/kill fallback; refactored running() to use subprocess.run with argument lists; updated stop() to dispatch platform-specific termination logic and handle missing os.killpg gracefully; modified locale and quoting handling per platform.
Comprehensive Test Coverage
tests/test_windows_compatibility.py, tests/test_executor.py
test_windows_compatibility.py provides 33 new test cases covering command template selection, quoting behaviour, path escaping, and Windows process lifecycle; test_executor.py adds 226 lines of platform-aware assertions, parametrised platform simulation tests, and integration tests for actual PostgreSQL startup on Windows/Unix/Darwin with locale validation.
CI/Workflow Updates
.github/workflows/single-postgres.yml, .github/workflows/tests.yml, .github/workflows/oldest-postgres.yml, .github/workflows/dockerised-postgres.yml
single-postgres.yml adds OS-specific pg_ctl discovery and basetemp path configuration; tests.yml introduces three Windows CI jobs (PostgreSQL 16/17/18) with dependency sequencing; oldest-postgres.yml restricts libpq installation to PyPy on Linux; dockerised-postgres.yml enables editable Pipenv mode.
Documentation
newsfragments/1182.feature.rst
Documents Windows compatibility feature including platform-specific command templates and Windows process termination method.

Sequence Diagrams

sequenceDiagram
    participant App as Application
    participant Exec as PostgreSQLExecutor
    participant Proc as subprocess.Popen
    participant PgCtl as pg_ctl

    App->>Exec: stop(sig=None)
    Exec->>PgCtl: subprocess.run([executable, "stop", "-D", datadir, "-m", "f"])
    PgCtl-->>Exec: returncode

    alt Windows Platform
        Exec->>Exec: _windows_terminate_process(None)
        Exec->>Proc: terminate()
        rect rgba(255, 100, 100, 0.5)
            Exec->>Proc: wait(timeout=30)
            Note over Proc: May raise TimeoutExpired
        end
        alt Timeout Occurred
            Exec->>Proc: kill()
            Exec->>Proc: wait()
        end
    else Unix Platform
        Exec->>Exec: TCPExecutor.stop(sig, exp_sig)
        Note over Exec: Uses os.killpg
    end

    Exec-->>App: Return
Loading
sequenceDiagram
    participant App as Application
    participant Exec as PostgreSQLExecutor
    participant SubProc as subprocess

    App->>Exec: running()
    Exec->>SubProc: run([executable, "status", "-D", datadir], check=False, shell=False)
    SubProc-->>Exec: CompletedProcess(returncode=...)
    
    alt returncode == 0
        Exec-->>App: True (running)
    else
        Exec-->>App: False (not running)
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

Suggested labels

Feature

Suggested reviewers

  • fizyk

Poem

🐰 Hop, hop, the Windows path we take,
Quotes and slashes for goodness sake!
From Unix soil to Windows land,
Process control, steadily planned,
Cross-platform magic, tested with care!

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main objective of the PR: refactoring PostgreSQLExecutor to support Windows compatibility for process management, which aligns with the substantial changes across the codebase.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Newsfragment Check ✅ Passed Newsfragment file newsfragments/1182.feature.rst exists and contains valid content confirming the fragment has been properly added with a recognised towncrier fragment type.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@pytest_postgresql/executor.py`:
- Around line 263-283: In stop(self, sig: Optional[int] = None, exp_sig:
Optional[int] = None) replace the subprocess.check_output call that builds a
shell string with a list-style invocation (e.g., [self.executable, "stop", "-D",
self.datadir, "-m", "f"]) and remove shell=True so subprocess runs the
executable directly; this avoids breaking paths with spaces and removes the
shell injection risk while keeping the same arguments and behavior before the
platform-specific termination logic (_windows_terminate_process / super().stop).
- Around line 53-66: The _get_base_command constructs the -o string with
unix_socket_directories unquoted which breaks for paths with spaces; update
_get_base_command to detect whitespace in the unixsocketdir variable and wrap
that value in double quotes (or escape quotes) when building the -o option so
the produced fragment becomes -c unix_socket_directories="/path/with space"
(referencing the unix_socket_directories token and BASE_PROC_START_COMMAND
assignment), and add a unit test that passes a datadir/unixsocketdir containing
a space to ensure the command line includes the quoted socket directory (or
alternatively, add explicit validation/documentation and raise a clear error
when whitespace is present).
🧹 Nitpick comments (1)
pytest_postgresql/executor.py (1)

231-262: Tidy up the termination helper API surface.

sig is unused in _windows_terminate_process, and _unix_terminate_process is currently unused. Either wire _unix_terminate_process into stop() for symmetry and use sig, or drop/rename the parameter to avoid dead code and lint noise.

Comment thread pytest_postgresql/executor.py Outdated
Comment thread pytest_postgresql/executor.py
@tboy1337 tboy1337 force-pushed the edit branch 2 times, most recently from 5d4fb91 to efa4633 Compare January 21, 2026 07:59
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@tests/test_windows_compatibility.py`:
- Around line 35-39: The test assertions in tests/test_windows_compatibility.py
don't match the actual string produced by _get_base_command(): update the
assertions to expect the escaped-quote form for unix_socket_directories (i.e.,
include the backslash-escaped double quotes around {unixsocketdir}) and assert
that the non-quoted form is not present; specifically change the positive
assertion referencing unix_socket_directories to look for
unix_socket_directories=\"{unixsocketdir}\" and keep the negative assertion for
unix_socket_directories='{unixsocketdir}' to ensure consistency with
_get_base_command().
- Around line 189-204: The test's expected_parts entry for
unix_socket_directories doesn't match the actual command string (which includes
escaped quotes), so update the expectation in the test to match the
implementation: replace the "-c unix_socket_directories=C:/temp/socket" entry
with the escaped-quote form that appears in executor.command (e.g., -c
unix_socket_directories=\"C:/temp/socket\"), keeping the rest of the
expected_parts and the loop over executor.command unchanged; reference the test
variable executor.command and the expected_parts list when making the change.
🧹 Nitpick comments (2)
pytest_postgresql/executor.py (2)

25-25: Unused import signal.

The signal module is imported but not used anywhere in the file. This appears to be a leftover from development.

🧹 Suggested fix
-import signal

250-269: Good refactor to list-based subprocess call.

The change from shell string to list format ([self.executable, "stop", "-D", self.datadir, "-m", "f"]) properly addresses the previous security concern and handles paths with spaces correctly.

One minor observation: the AttributeError fallback (lines 263-268) uses string matching "killpg" in str(e) which is somewhat fragile. Consider whether this fallback is still needed given the explicit platform.system() check now handles Windows upfront.

Comment thread tests/test_windows_compatibility.py Outdated
Comment thread tests/test_windows_compatibility.py Outdated
@tboy1337 tboy1337 requested a review from fizyk January 21, 2026 08:33
@tboy1337 tboy1337 force-pushed the edit branch 2 times, most recently from b02c61b to 4a0b22e Compare January 21, 2026 10:24
Comment thread pytest_postgresql/executor.py Outdated
@tboy1337 tboy1337 force-pushed the edit branch 2 times, most recently from 059e4bc to 54140ac Compare January 29, 2026 05:40
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@pytest_postgresql/executor.py`:
- Around line 226-246: The parameter sig in _windows_terminate_process is
intentionally unused and triggers Ruff ARG002; either rename it to _sig to
indicate it’s intentionally unused or keep sig and add a local lint suppression
(e.g., append a noqa comment for ARG002) where the function is defined to
silence the warning; update the function signature (or add the noqa) in the
_windows_terminate_process definition and run linters to confirm the ARG002
warning is resolved.

Comment thread pytest_postgresql/executor.py Outdated
Copy link
Copy Markdown
Member

@fizyk fizyk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tboy1337 are we able to add ci windows-based tests?

Comment thread tests/test_windows_compatibility.py Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.github/workflows/single-postgres.yml (1)

82-86: ⚠️ Potential issue | 🟡 Minor

Artifact upload path is Unix-only.

/tmp/pytest-of-runner/** on line 86 won't match anything on Windows. This is gated behind if: failure() so it won't fail the build, but Windows test failure artefacts will be silently lost. Consider adding a platform-conditional path or using ${{ runner.temp }}.

🤖 Fix all issues with AI agents
In @.github/workflows/single-postgres.yml:
- Around line 59-62: The workflow hardcodes POSTGRESQL_EXEC to
/usr/lib/postgresql/... which breaks macOS runners; change the step that sets
POSTGRESQL_EXEC (the block under the if: runner.os != 'Windows') to detect
pg_ctl on Unix-like systems instead of a Debian path — use command -v pg_ctl and
if that fails try macOS Homebrew locations (e.g.,
/opt/homebrew/opt/postgresql@${{ inputs.postgresql }}/bin/pg_ctl and
/usr/local/opt/postgresql@${{ inputs.postgresql }}/bin/pg_ctl) or set a fallback
to the current Debian path; ensure the final value exported as POSTGRESQL_EXEC
is the first existing pg_ctl found so CI on macos_postgres_* with
ankane/setup-postgres works correctly.
🧹 Nitpick comments (4)
pytest_postgresql/executor.py (2)

226-246: Broadly swallowing exceptions in cleanup is acceptable but consider logging.

The except (OSError, AttributeError): pass on lines 244–246 silently discards all OSError variants (including permission errors) and AttributeError. For a teardown helper this is pragmatic, but a debug-level log would aid troubleshooting when processes fail to terminate.


261-266: String-based AttributeError matching is fragile.

Checking "killpg" in str(e) couples the fallback to the exact wording of CPython's error message, which could change across versions or implementations. Consider catching the missing attribute directly.

Proposed fix
         except AttributeError as e:
-            # Fallback for edge cases where os.killpg doesn't exist
-            if "killpg" in str(e):
+            # Fallback for edge cases where os.killpg doesn't exist (e.g. Windows)
+            if not hasattr(os, "killpg"):
                 self._windows_terminate_process(sig)
             else:
                 raise
tests/conftest.py (1)

7-9: Remove the commented-out import rather than leaving dead code.

The commented-out line still triggers a Ruff warning (RUF100) for the stale noqa directive. Since the comment on line 8 already explains the rationale, the old import line adds no value.

Proposed fix
 
 # Plugin is registered via entry point in pyproject.toml - no need to import here
-# from pytest_postgresql.plugin import *  # noqa: F403,F401
tests/test_windows_compatibility.py (1)

74-98: Patch target for subprocess.check_output should be where it's looked up.

The patch patch("subprocess.check_output") works because executor.py uses import subprocess and then subprocess.check_output(...), so patching the module attribute is fine. However, best practice is to patch where the name is used: pytest_postgresql.executor.subprocess.check_output. This avoids accidentally affecting other code if tests are ever run in parallel or the import style changes.

This applies to all test methods in this class that patch subprocess.check_output.

Comment thread .github/workflows/single-postgres.yml Outdated
@tboy1337
Copy link
Copy Markdown
Contributor Author

@coderabbitai resume

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 11, 2026

✅ Actions performed

Reviews resumed.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@tests/test_windows_compatibility.py`:
- Around line 127-155: The test fails on Unix because os.killpg exists so the
stop() except branch re-raises; to exercise the fallback, remove killpg from the
executor module's os before calling stop: inside the test's with-block, import
sys and call delattr(sys.modules['pytest_postgresql.executor'].os, "killpg") (or
use monkeypatch.delattr on that module's os) so that hasattr(os, "killpg") is
False when PostgreSQLExecutor.stop() runs; keep references to
PostgreSQLExecutor.stop, os.killpg, and _windows_terminate_process to locate the
code to change.
🧹 Nitpick comments (3)
pytest_postgresql/executor.py (2)

32-34: Logger initialisation breaks import grouping.

The logger = logging.getLogger(__name__) statement is sandwiched between two mirakuru imports. Move it after all top-level imports to keep the import block contiguous and PEP 8–compliant.

Suggested reordering
 from mirakuru import TCPExecutor
-
-logger = logging.getLogger(__name__)
 from mirakuru.exceptions import ProcessFinishedWithError
 from packaging.version import parse
 
 from pytest_postgresql.exceptions import ExecutableMissingException, PostgreSQLUnsupported
+
+logger = logging.getLogger(__name__)

229-254: _windows_terminate_process looks good overall; minor nit on redundant pass.

The graceful-then-force-kill approach is sound. However, the pass on line 254 is redundant — the logger.debug(...) call already satisfies the except block body.

Suggested fix
             logger.debug(
                 "Exception during Windows process termination: %s: %s",
                 type(e).__name__,
                 e,
             )
-            pass
tests/test_windows_compatibility.py (1)

74-98: Windows stop test: consider asserting the exact arguments passed to check_output.

The test asserts mock_subprocess.assert_called_once() but doesn't verify the arguments. Since stop() now uses list-form args ([self.executable, "stop", "-D", self.datadir, "-m", "f"]), asserting the call args would catch regressions in the command construction.

Optional enhancement
             # Should call pg_ctl stop and Windows terminate
-            mock_subprocess.assert_called_once()
+            mock_subprocess.assert_called_once_with(
+                ["/path/to/pg_ctl", "stop", "-D", "/tmp/data", "-m", "f"],
+            )
             mock_terminate.assert_called_once()

Comment thread tests/test_windows_compatibility.py
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@pytest_postgresql/executor.py`:
- Around line 244-246: Replace the blocking self.process.wait() after
self.process.kill() with a timed wait and a fallback path: call
self.process.wait(timeout=...) (or poll in a short loop) and catch
subprocess.TimeoutExpired, then log a warning and avoid hanging (optionally
attempt a forceful termination or continue without blocking); update the code
around self.process.kill() / self.process.wait() in executor.py to use a timeout
and warning on failure to reap the process.
🧹 Nitpick comments (1)
tests/test_windows_compatibility.py (1)

74-100: Consider a more precise mock assertion for _windows_terminate_process.

mock_terminate.assert_called_once() on line 99 does not verify the arguments. Since stop() calls self._windows_terminate_process(sig) (where sig defaults to None), using assert_called_once_with(None) would make the test stricter and catch regressions if the call signature changes.

Proposed fix
-            mock_terminate.assert_called_once()
+            mock_terminate.assert_called_once_with(None)

Comment thread pytest_postgresql/executor.py Outdated
@tboy1337 tboy1337 requested a review from fizyk February 11, 2026 15:38
Comment thread .github/workflows/single-postgres.yml Outdated
Comment thread .github/workflows/single-postgres.yml
Comment thread tests/conftest.py Outdated
Comment thread tests/conftest.py Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @.github/workflows/single-postgres.yml:
- Around line 50-62: The Windows step "Detect PostgreSQL path on Windows"
currently may leave POSTGRESQL_EXEC unset if neither the hardcoded Test-Path
lookup nor Get-Command finds pg_ctl; update the pwsh run block so that after
attempting both Test-Path and Get-Command you check whether $pgPath is set and,
if not, write an explicit error and exit non‑zero (e.g., write-host/error then
exit 1) so downstream steps that rely on POSTGRESQL_EXEC (the env var) fail fast
and consistently rather than receiving an empty --postgresql-exec.

Comment thread .github/workflows/single-postgres.yml
@tboy1337
Copy link
Copy Markdown
Contributor Author

@coderabbitai resume

tboy1337 and others added 29 commits April 15, 2026 09:59
- Added steps to install the package in editable mode before running tests in dockerised-postgres.yml, oldest-postgres.yml, and single-postgres.yml.
- Streamlined the testing process by ensuring the package is available in the current environment for all workflows.
- Modified the package installation command to include the --no-deps flag, ensuring that only the editable package is installed without its dependencies before running tests.
- Added verification step to ensure pg_ctl is found in expected locations during the GitHub Actions workflow for single-postgres.yml.
- Implemented error logging and exit strategy if PostgreSQL is not detected, improving robustness of the setup process.
- Introduced separate command templates for Unix and Windows to handle quoting and configuration differences.
- Updated tests to validate the correct command template is used based on the operating system.
- Enhanced test coverage for command formatting, ensuring proper handling of paths with spaces on Unix and omission of unnecessary parameters on Windows.
- Updated the pg_ctl path in single-postgres.yml to include the .exe extension for compatibility with Windows environments, ensuring proper execution of PostgreSQL commands.
- Changed the conftest file generation to use a more explicit pytest_plugins declaration for better clarity and compatibility with pytest's plugin system.
…for improved clarity

- Changed the pytest_plugins declaration in the conftest file generation to specify the plugin path explicitly, enhancing compatibility with pytest's plugin system.
…tgreSQLExecutor

- Added tests to verify correct command templates for Windows, Unix, and Darwin platforms, ensuring proper handling of `unix_socket_directories` and `log_destination`.
- Implemented checks for locale settings on Darwin and preserved quoting for `postgres_options` across different platforms.
- Improved test assertions for command generation with special characters and empty parameters, enhancing overall test robustness.
…andling

- Introduced a pytest fixture to set Windows-compatible locale environment variables, ensuring compatibility with PostgreSQL's initdb on Windows.
- Updated test cases for PostgreSQL start commands across Windows, Unix, and Darwin platforms to include a password parameter, enhancing test coverage and consistency.
… fixture from conftest.py

- Modified locale settings in executor.py to ensure compatibility across Darwin and Windows platforms.
- Removed the Windows locale setup fixture from conftest.py as the locale handling is now managed directly in executor.py, simplifying the test configuration.
…Executor

- Updated the test case to create a dedicated socket directory for Unix systems, improving clarity and organization in the test setup.
- Adjusted the path for the `unixsocketdir` parameter to use the newly created socket directory, ensuring proper configuration for PostgreSQLExecutor.
- Modified the upload path for pytest results to include both the temporary runner directory and a specific /tmp directory, ensuring comprehensive coverage of test artifacts during the workflow execution.
…etemp for improved temporary directory handling

- Added the --basetemp option to pytest commands to specify a base temporary directory, enhancing the management of test artifacts during execution.
- Simplified the upload path for pytest results to focus on the temporary runner directory, ensuring efficient artifact collection.
…t collection

- Simplified the upload path for pytest results by removing the specific wildcard in the temporary directory, ensuring more efficient collection of test artifacts during the workflow execution.
Upgraded fizyk/actions-reuse pipenv-setup action from v4.2.1 to v4.4.0 which includes built-in support for editable package installation via the editable flag. This simplifies the workflows by removing the explicit pip install -e . steps.

Changes:
- Updated pipenv-setup to v4.4.0 in all workflow files
- Added editable: true parameter to pipenv-setup steps
- Removed separate "Install package in editable mode" steps from dockerised-postgres.yml, single-postgres.yml, and oldest-postgres.yml

This aligns with the upstream pattern established in pytest-mongo and reduces workflow complexity while maintaining the same functionality.

Co-authored-by: Cursor <[email protected]>
… checks

- Upgraded the pipenv-run action to v4.2.1 in dockerised-postgres.yml, single-postgres.yml, and oldest-postgres.yml for consistency across workflows.
- Refined the conditional check for installing libpq to use matrix.python-version instead of inputs.python-versions in oldest-postgres.yml and single-postgres.yml, improving clarity and accuracy.

These changes enhance the maintainability and consistency of the workflow configurations.
…est_postgres_options_plugin.py

- Updated the socket directory creation in test_executor.py to use basetemp for improved path management, addressing Unix domain socket length limitations.
- Removed unnecessary conftest configuration in test_postgres_options_plugin.py to streamline the pytest setup.

These changes enhance the clarity and efficiency of the test configurations.
… assertions

- Removed unnecessary spaces in the command templates for both Unix and Windows to ensure proper execution of PostgreSQL commands.
- Updated test assertions in test_executor.py and test_windows_compatibility.py to check for the correct formatting of the `unix_socket_directories` parameter, ensuring consistency across platforms.

These changes enhance the reliability of command execution and improve test accuracy.
…utor.py

- Adjusted assertions in test_actual_postgresql_start_unix and test_actual_postgresql_start_darwin to check for correct formatting of the `unix_socket_directories` parameter, ensuring consistency in command output.

These changes improve the accuracy of the tests related to PostgreSQL command execution.
- Updated the platform_name parameter in test_executor.py to include "FreeBSD", expanding the test coverage for platform-specific functionality.

This change enhances the robustness of the tests by ensuring compatibility with FreeBSD.
- Updated the --basetemp option in pytest commands to specify a consistent temporary directory for test artifacts, improving organization and clarity in the workflow.
- Adjusted the artifact upload path to reflect the new temporary directory structure, ensuring efficient collection of test results.

These changes enhance the maintainability and reliability of the testing workflow.
…tibility.py

- Changed the docstring to use a raw string literal for better handling of backslashes in UNC path examples.
- Clarified the description of UNC paths to ensure accurate representation of their format.

These updates improve the clarity and correctness of the test documentation.
The [email protected] upgrade and editable: true flag additions have
been extracted into a dedicated PR (dbfixtures#1294). Remove those changes from
this branch to avoid duplication and conflicts once that PR is merged.

Made-with: Cursor
- Updated the command templates in `PostgreSQLExecutor` to ensure the executable path is always double-quoted, improving compatibility with paths containing spaces.
- Modified tests in `test_windows_compatibility.py` to reflect the changes in command formatting, ensuring that single-quoted PostgreSQL options are preserved correctly within double-quoted command strings.
- Added new tests to verify that the `running()` method properly quotes the executable and datadir, enhancing robustness against shell parsing issues.
- Updated the command generation in `PostgreSQLExecutor` to escape single quotes in the `unixsocketdir` parameter, ensuring valid syntax for PostgreSQL GUC strings.
- Refactored the `running()` method to use `subprocess.run` instead of `subprocess.getstatusoutput`, improving compatibility and security by avoiding shell parsing.
- Added regression tests in `test_windows_compatibility.py` to verify correct escaping of apostrophes in `unixsocketdir` and ensure robust command generation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants